package com.hiwhitley.easy.day23;

/**
 * Created by hiwhitley on 2016/10/15.
 */
public class ReverseBits_190 {
    public static int reverseBits(int n) {
        StringBuilder stringBuilder = new StringBuilder(Integer.toBinaryString(n));
        int len = stringBuilder.length();
        if (stringBuilder.length() < 32) {
            for (int i = 0; i < 32 - len; i++) {
                stringBuilder.insert(0, '0');
            }
        }
        return Integer.parseUnsignedInt(stringBuilder.reverse().toString(), 2);
    }

    public static void main(String[] args) {
        System.out.println(reverseBits(43261596));
    }
}
